package com.eve.crp;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import com.eve.crp.Client;

public class ClientValidator implements Validator {

	@Override
	public boolean supports(Class clazz) {
		return Client.class.isAssignableFrom(clazz);
	}

	@Override
	public void validate(Object target, Errors errors) {
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "firstname", "required.firstname");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "lastname", "required.lastname");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "street", "required.street");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "needDescription", "required.needDescription");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "birthdate", "required.birthdate");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "needDate", "required.needDate");
	}
	

}
